#!/usr/bin/expect -f
set timeout 60

# 设置目标主机和用户名
set host "192.168.20.22"
set user "csst"
set password "123"

# 启动 SSH 连接
spawn ssh -l $user $host

# 等待密码提示
expect {
    "password:" {
        send "$password\r"
    }
    timeout {
        send_user "SSH connection timed out.\n"
        exit 1
    }
    eof {
        send_user "SSH connection closed.\n"
        exit 1
    }
}

# 交互式模式
interact
